﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using VideoStream.Model;

namespace VideoStream.Common
{
    public class User32
    {
        // api
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        [DllImport("User32.dll", EntryPoint = "FindWindow")]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("User32.dll", EntryPoint = "ShowWindow")]
        private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);


        public static void ShowWindows(IntPtr hwnd)
        {
            //SendMessage(hwnd, (int)WMSG.WM_SHOWWINDOW, 0, 0);
            //SendMessage(hwnd, (int)WMSG.WM_SYSCOMMAND, (int)WM_SYSCOMMAND_WPARAM.SC_MINIMIZE, 0);
            //SendMessage(hwnd, (int)WMSG.WM_SYSCOMMAND, (int)WM_SYSCOMMAND_WPARAM.SC_RESTORE, 0);
            ShowWindow(hwnd, (int)ShowWindow_Param.SW_SHOWNA);

            //SendMessage(hwnd, (int)WMSG.WM_ACTIVATE, (IntPtr)WM_ACTIVATE_MSG.WA_CLICKACTIVE, IntPtr.Zero);
            //SendMessage(hwnd, (int)WMSG.WM_ACTIVATE, IntPtr.Zero, IntPtr.Zero);
        }

        public static IntPtr FindWindow(string windowName)
        {
            return FindWindow(null, windowName);
        }
    }
}
